home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5010 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.3 KB  |  78 lines

  1. Path: sdd.hp.com!inn
  2. From: Laura Mansfield <laura>
  3. Newsgroups: comp.lang.c++
  4. Subject: a question about abstract base classes and libraries
  5. Date: 2 Feb 1996 03:27:29 GMT
  6. Organization: Hewlett-Packard, San Diego
  7. Message-ID: <4es0b1$au7@news.sdd.hp.com>
  8. NNTP-Posting-Host: hpsdlgd6.sdd.hp.com
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.12 (X11; I; HP-UX A.09.05 9000/730)
  13. X-URL: news:comp.lang.c++
  14.  
  15. A question I'm hoping someone can answer ~
  16.  
  17. I'm writing a library, lib.a, to be linked to by some client code that
  18. will use its services.  The client code will include a file, lib.h, which
  19. defines the class interface to lib.a.  The classes have member functions
  20. that the client code will use to do some inventory management.
  21.  
  22. I'd like to hide the private data members of this class, and so have
  23. decided to create and abstract base class, and make visible to the client
  24. code only the derived class. To better explain, here's an example:
  25.  
  26. In my library code:
  27.  
  28. class Abstract
  29. {
  30.  
  31.   protected:
  32.  
  33.   int a;
  34.   int b;
  35.  
  36.   public:
  37.  
  38.   virtual void func( void ) = 0;
  39. };
  40.  
  41. In lib.h:
  42.  
  43. class ClassA : public abstract
  44. {
  45.  
  46.   public:
  47.  
  48.   virtual void func( void );
  49. };
  50.  
  51. But I'm beginning to realize I can't really do this w/out defining
  52. class Abstract in lib.h.  I tried to do "class Abstract;" at the beginning
  53. of lib.h, but I think this only works for pointers.
  54.  
  55. Can anyone help me w/ what to do here?
  56.  
  57. Laura
  58. -- 
  59.  
  60. ************************************************************************
  61.  
  62. Laura C. Mansfield                              _/_/_/_/_/_/_/_/_/_/_/
  63. Hewlett-Packard Company                         _/        _/        _/
  64. San Diego Printer Division                                _/
  65. MS-60U360                                     _/_/_/_/_/  _/  _/      _/
  66. 16399 W. Bernardo Dr.                         _/      _/  _/  _/_/  _/_/
  67. San Diego, CA 92127-1899                      _/_/_/_/_/  _/  _/  _/  _/
  68.                                               _/      _/  _/  _/      _/
  69.                                               _/      _/  _/  _/      _/
  70.                                                           _/
  71. Gig' Em Aggies!                                       _/_/_/_/_/
  72.  
  73.  
  74. "Truth is more than an opposing point of view." - Susan Ashton
  75.  
  76. ************************************************************************
  77.  
  78.